# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
# from scipy.spatial import ConvexHull
#
# # 生成三个Pareto前沿的数据
# np.random.seed(0)
# # Front 1: 最小值
# front1 = np.random.rand(30, 3) * 1
# # Front 2: 中等值
# front2 = np.random.rand(30, 3) * 1.5 + 0.5
# # Front 3: 较大值
# front3 = np.random.rand(30, 3) * 2 + 1
#
# # 设置3D图形
# fig = plt.figure(figsize=(12, 8))
# ax = fig.add_subplot(111, projection='3d')
#
# # 定义每个Pareto前沿的颜色和标签
# fronts = [(front1, 'blue', 'Front 1'),
#           (front2, 'green', 'Front 2'),
#           (front3, 'red', 'Front 3')]
#
# # 绘制每个前沿的曲面
# for front, color, label in fronts:
#     # 创建每个前沿的凸包，以可视化其为曲面
#     hull = ConvexHull(front)
#     for simplex in hull.simplices:
#         ax.plot_trisurf(front[simplex, 0], front[simplex, 1], front[simplex, 2], color=color, alpha=0.3)
#
# # 选取一些点进行标记
# key_points = [front1[0], front1[10], front2[5], front2[15], front3[20], front3[25]]
# labels = ['A', 'B', 'C', 'D', 'E', 'F']  # 标记的字母
#
# # 在图上绘制这些点并标记
# for point, label in zip(key_points, labels):
#     ax.scatter(point[0], point[1], point[2], color='black', s=50)
#     ax.text(point[0], point[1], point[2], f"{label} ({point[0]:.2f}, {point[1]:.2f}, {point[2]:.2f})",
#             size=12, zorder=1, color='k')
#
# # 设置标签和美化图形
# ax.set_xlabel('目标 1')
# ax.set_ylabel('目标 2')
# ax.set_zlabel('目标 3')
# ax.set_title('3D Pareto Front Surfaces - Minimization (Lower is Better)')
# plt.show()

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.spatial import ConvexHull

# 生成三个Pareto前沿的数据
np.random.seed(0)
# Front 1: 最小值
front1 = np.random.rand(30, 3) * 1
# Front 2: 中等值，增加z方向的偏移
front2 = np.random.rand(30, 3) * 1.5 + np.array([0.5, 0.5, 2])
# Front 3: 较大值，进一步增加z方向的偏移
front3 = np.random.rand(30, 3) * 2 + np.array([1, 1, 4])

# 设置3D图形
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111, projection='3d')

# 定义每个Pareto前沿的颜色和标签
fronts = [(front1, 'blue', 'Front 1'),
          (front2, 'green', 'Front 2'),
          (front3, 'red', 'Front 3')]

# 绘制每个前沿的曲面
for front, color, label in fronts:
    # 创建每个前沿的凸包，以可视化其为曲面
    hull = ConvexHull(front)
    for simplex in hull.simplices:
        ax.plot_trisurf(front[simplex, 0], front[simplex, 1], front[simplex, 2], color=color, alpha=0.3)

# 选取一些点进行标记
key_points = [front1[0], front1[10], front2[5], front2[15], front3[20], front3[25]]
labels = ['A', 'B', 'C', 'D', 'E', 'F']  # 标记的字母

# 在图上绘制这些点并标记
for point, label in zip(key_points, labels):
    ax.scatter(point[0], point[1], point[2], color='black', s=50)
    ax.text(point[0], point[1], point[2], f"{label}", size=12, zorder=1, color='k')

# 设置标签和美化图形
ax.set_xlabel('目标 1')
ax.set_ylabel('目标 2')
ax.set_zlabel('目标 3')
ax.set_title('3D Pareto Front Surfaces - Minimization (Lower is Better)')
plt.show()

